# 整型数组求和
def sum_c(array):
    s = 0
    for i in array:
        s += i
    return s


# 数组求最大值
def max_c(array):
    s = array[0]
    for i in array:
        if i > s:
            s = i
    return s


# 数组求最小值
def min_c(array):
    s = array[0]
    for i in array:
        if i < s:
            s = i
    return s


# 数组求元素的频数
def pinshu_c(array):
    s = {}
    for i in array:
        if i not in s:
            s[i] = 1
        else:
            s[i] += 1
    return s


def variance(array):
    mean = sum_c(array) / len(array)
    va = 0
    for i in array:
        t = (i - mean) * (i - mean)
        va += t
    return t / (len(array) - 1)


if __name__ == '__main__':
    a = [1, 5, 6, 7, 100000]
    print(variance(a))
